import request from "@/netword/request";


const fun = {};


// 分页查询所有信息
fun.getList = async (news) => {
    const res = await request({
        url: "/a/content/news/list",
        method: "post",
        params: {
            newsTitle: news.newsTitle,
            newsType: news.newsType,
            pageNo: news.pageNo,
            pageSize: news.pageSize,
        }
    })
    return res.data;
}



//保存数据
fun.saveNews = async (news) => {
    const res = await request({
        url: "/a/content/news/save",
        method: "put",
        params: {
            newsTitle: news.newsTitle,
            newsType: news.newsType,
            newsContent: news.newsContent,
            sort:news.sort,
        }
    })
    return res.data;
}



//更新数据
fun.updateNews = async (news) => {
    const res = await request({
        url: "/a/content/news/update",
        method: "post",
        params: {
            id: news.id,
            newsTitle: news.newsTitle,
            newsType: news.newsType,
            newsContent: news.newsContent,
            sort:news.sort,
        }
    })
    return res.data;
}



//修改数据状态（正常，停用，删除）
fun.saveStatus = async (id,status) => {
    const res = await request({
        url: "/a/content/news/updateStatus",
        method: "post",
        params: {
            id: id,
            status:status
        }
    })
    return res.data;
}


//查询单条数据
fun.getNews = async (id) => {
    const res = await request({
        url: "/a/content/news/get",
        method: "get",
        params: {
            id: id
        }
    })
    return res.data;
}


export default fun;